<style lang="less">
    @import './login.less';
</style>

<template>
    <div class="login" @keydown.enter="handleSubmit">
        <div class="login-con">
            <Card :bordered="false">
                <p slot="title">
                    <Icon type="log-in"></Icon>
                    欢迎登录
                </p>
                <div class="form-con">
                    <Form ref="loginForm" :model="form" :rules="rules">
                        <div>
                            <div style="width:100px;background:red;margin:auto;height:100px;">
                                <img src="https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=3448484253,3685836170&fm=27&gp=0.jpg" style="width:100%">
                            </div>
                        </div>
                        <div style="height:50x;line-height:50px;width:100%;text-align: center">admin</div>
                        
                        <FormItem>
                            <Button @click="handleSubmit" type="primary" long>授权登录</Button>
                        </FormItem>
                    </Form>
                </div>
            </Card>
        </div>
    </div>
</template>

<script>
import Cookies from 'js-cookie';
export default {
    data () {
        return {
            form: {
                userName: '18516094829',
                password: '1234'
            },
            rules: {
                userName: [
                    { required: true, message: '账号不能为空', trigger: 'blur' }
                ],
                password: [
                    { required: true, message: '密码不能为空', trigger: 'blur' }
                ]
            }
        };
    },
    methods: {
        handleSubmit () {
            var _this = this;
            Cookies.set('token', 'admin',{ expires: 1}); //一天过期
            Cookies.set('user', 'admin',{ expires: 1}); //一天过期
            Cookies.set('access', 1);
            _this.$store.commit('setAvator', 'https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=3448484253,3685836170&fm=27&gp=0.jpg');                              
            _this.$Message.success("授权登录.....");
            setTimeout(()=>{
                _this.$router.push({name: 'home_index'});
            },100)
        }
    }
};
</script>

<style>

</style>
